package com.minjiang.blog.config;

import com.minjiang.blog.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    /**
     * web添加拦截器
     * addPathPatterns 过滤路径
     * excludePathPatterns 排除路径
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        添加自定义拦截器
        registry.addInterceptor(new LoginInterceptor())
                //拦截路径
                .addPathPatterns("/admin/**")
                //排除拦截路径
                .excludePathPatterns("/admin")
                //排除拦截路径
                .excludePathPatterns("/admin/login");
    }
}
